//
//  XMNetwork+message.m
//  XMJJ_zml
//
//  Created by apple on 2025/5/12.
//

#import "XMNetwork+message.h"

@implementation XMNetwork (message)

/**
 获取消息
 */
- (void)getMessageWithUserId:(NSString *)userId
                     success:(void (^)(id _Nonnull))successBlock
                     failure:(void (^)(NSError * _Nonnull))failureBlock {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters safe_setObject:userId forKey:@"id"];
    [self getDataWithPath:messageList
               parameters:parameters
                needToken:YES
                  headers:@{}
                  success:^(id  _Nonnull responseObject) {
        successBlock (responseObject);
    } failure:^(NSError * _Nonnull error) {
        failureBlock (error);
    }];
}

/**
 会话列表
 */
- (void)getContactListWithUserId:(NSString *)userId
                       timeStamp:(NSInteger)timeStamp
                      startIndex:(NSInteger)startIndex
                         success:(void (^)(id _Nonnull))successBlock
                         failure:(void (^)(NSError * _Nonnull))failureBlock {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters safe_setObject:userId forKey:@"fromAccount"];
    [parameters safe_setObject:@(timeStamp) forKey:@"timeStamp"];
    [parameters safe_setObject:@(startIndex) forKey:@"startIndex"];
    [parameters safe_setObject:@"15" forKey:@"assistFlags"];
    [self postDataWithPath:getContactListUrl
                parameters:parameters
                 needToken:YES
                   headers:@{}
                   success:^(id  _Nonnull responseObject) {
        successBlock (responseObject);
    } failure:^(NSError * _Nonnull error) {
        failureBlock (error);
    }];
}

@end
